<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set value="<%=request.getContextPath()%>" var="ctx"></c:set>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8">
	<meta name="keywords" content="关键字台">
    <meta name="description" content="描述"> 
    <link href="${ctx}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="${ctx}/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet"> 
	<link href="${ctx}/css/plugins/toastr/toastr.min.css" rel="stylesheet" >
	<title>积分配置</title>
<!-- Web Uploader -->

</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
           <div class="col-sm-12">
           		<div class="ibox float-e-margins">
           			<div class="ibox-title">
                        <div class="row">
                           <div class="col-sm-12">
                                <h3>积分配置</h3>
                           </div>
                        </div>
                        </div>
                   

          
	         <div class="ibox-content">
				<form class="form-horizontal" action="${ctx}/score/scoreUpd"
					name="scoreInitform" id="scoreInitform" method="post">
					<div class="hr-line-dashed"></div>
					
					<div class="row">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8">
					
								<div class="form-group">
									<label class="col-sm-4 control-label">扫码最低积分：</label>
									<div class="col-sm-5">
									<input type="text" class="form-control" name="score_start"
											id="score_start" value="${msg.data.score_start}" placeholder="请输入扫码最低积分" maxlength="10"/>
										<input type="hidden" name="id"  value="${msg.data.id}"/> 
									</div>
								</div>
								<div class="form-group">
								<label class="col-sm-4 control-label">扫码最高积分：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="score_end" placeholder="请输入扫码最高积分" maxlength="10"
											id="score_end"  value="${msg.data.score_end}"/>
									</div>
								</div>
								<div class="form-group">
								<label class="col-sm-4 control-label">关注送积分：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="attention_score" placeholder="请输入关注送积分" maxlength="10"
											id="attention_score"  value="${msg.data.attention_score}"/>
									</div>
								</div>
								<div class="form-group">
								<label class="col-sm-4 control-label">分享送积分：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="share_score" placeholder="请输入分享送积分" maxlength="10"
											id="share_score"  value="${msg.data.share_score}"/>
									</div>
								</div>
								<div class="hr-line-dashed"></div>
								<div class="form-group">
								<label class="col-sm-4 control-label">初始签到积分：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="default_score" placeholder="请输入初始签到积分" maxlength="10"
											id="default_score" value="${msg.data.default_score}"/>
									</div>
								</div>
								<div class="form-group">
								<label class="col-sm-4 control-label">连续签到累加积分：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="add_score" placeholder="请输入连续签到累加积分" maxlength="10"
											id="add_score" value="${msg.data.add_score}"/>
									</div>
								</div>
								<div class="form-group">
								<label class="col-sm-4 control-label">连续签到上限（天）：</label>
								<div class="col-sm-5">							
										<input type="text" class="form-control" name="days" placeholder="请输入连续签到上限" maxlength="10"
											id="days" value="${msg.data.days}"/>
									</div>
								</div>
							<div class="form-group">
									<label class="col-sm-4 control-label"></label>
									<div class="col-sm-5">
										<button class="btn btn-large btn-primary"  id="saveBtn" name="saveBtn"  onclick="save();return false;">&#8194;保存&#8194;</button>
									</div>
								</div>
					</div>
					</div>
				</form>
			</div>
		
		 </div>
	</div>
	</div>
	</div>
	
	
	 <!-- 全局js -->
    <script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script src="${ctx}/js/content.js?v=1.0.0"></script>
	<script src="${ctx}/js/plugins/toastr/toastr.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery.validate.min.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#scoreInitform").validate({
		debug : false,
		rules : {
			score_start : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			score_end : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			default_score : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			add_score : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			days : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			attention_score : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			},
			share_score : {
				required : true,
				digits:true,
				minlength : 1,
				maxlength : 3
			}
		},
		messages : {
			score_start : {
				required : "请输入随机送积分数",
				digits: "积分必须输入正整数",
				minlength: "积分数不能小于0",
				maxlength:"积分数最多为3位"
			},
			score_end : {
				required : "请输入随机送积分数",
				digits: "积分必须输入正整数",
				minlength: "积分数不能小于0",
				maxlength:"积分数最多为3位"
			},
			default_score : {
				required : "请输入初始签到积分数",
				digits: "积分必须输入正整数",
				minlength: "积分数不能小于0",
				maxlength:"积分数最多为3位"
			},
			add_score : {
				required : "请输入连续签到累加积分数",
				digits: "积分必须输入正整数",
				minlength: "积分数不能小于0",
				maxlength:"积分数最多为3位"
			},
			days : {
				required : "请输入连续签到上限天数",
				digits: "天数必须输入正整数",
				minlength: "天数不能小于0",
				maxlength:"天数最多为3位"
			},
			attention_score : {
				required : "请输入关注送积分数",
				digits: "积分必须输入正整数",
				minlength: "积分数不能小于0",
				maxlength:"积分数最多为3位"
			},
			share_score : {
				required : "请输入分享送积分数",
				digits: "积分必须输入正整数",
				minlength: "积分不能小于0",
				maxlength:"积分最多为3位"
			}
		}
	});
});
    
    function save(){
    	toastr.options = {
    			  "closeButton": false,
    			  "debug": false,
    			  "progressBar": false,
    			  "positionClass": "toast-top-center",
    			  "onclick": null,
    			  "showDuration": "400",
    			  "hideDuration": "1000",
    			  "timeOut": "2000",
    			  "extendedTimeOut": "1000",
    			  "showEasing": "swing",
    			  "hideEasing": "linear",
    			  "showMethod": "fadeIn",
    			  "hideMethod": "fadeOut"
    			}
    	//表单验证
		if (!$("#scoreInitform").valid()){
			return;
		}else{
    		$.ajax({
    			type : "POST",
    			url : "${ctx}/score/scoreUpd", //换成你要请求的action, paperId 是url参数
    			data : $("#scoreInitform").serialize(),
    			async : false,
    			error : function(msg) {
    				toastr.error(msg.message);
    			},
    			success : function(data) {
    				if(data.state == 0){
    					toastr.success(data.message);
    				}else{
    					toastr.error(data.message);
    				}
    			}
    		});
		}
    }
</script>
</body>
</html>